home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11914 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: argonet.co.uk!argbe15
  2. From: Dave Mullard <dmullard@argonet.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: How to get at base class fields from member functions?
  5. Date: Sun, 17 Mar 1996 00:49:35
  6. Organization: UnipalmPIPEX server (post doesn't reflect views of UnipalmPIPEX
  7. Distribution: world
  8. Message-ID: <internews46B00D1FBD@argonet.co.uk>
  9. Reply-To: Dave Mullard <dmullard@argonet.co.uk>
  10. NNTP-Posting-Host: aj075.du.pipex.com
  11. X-Newsreader: VTi Voyager InterNews 0.15 for Acorn RISC OS (Patched by RA)
  12.  
  13. Given three classes A, B and C I want to have multiple As for each B and
  14. multiple Bs for each C. To do this I could create the following.
  15.  
  16. class b1 : public B
  17. {
  18. A a1;
  19. A a2;
  20. A a3;
  21. };
  22.  
  23. class b2 : public B
  24. {
  25. A a1;
  26. A a2;
  27. A a3;
  28. A a4;
  29. A a5;
  30. };
  31.  
  32. class c1 : public C
  33. {
  34. b1 b1;
  35. b2 b2;
  36. };
  37.  
  38. The question is, how within functions for class B do I access fields
  39. within class C, and similarly, how within the class A functions do I
  40. access fields within class B?
  41.  
  42. Any help would be appreciated.
  43.  
  44. Thanks,
  45. ...
  46. -- 
  47.  Dave Mullard <dmullard@argonet.co.uk>
  48.  
  49.